﻿Imports Utilidades
Imports Excepciones
Imports Negocio
Imports Servicios
Imports System.IO

Public Class frmABMPerfil

    Private _perfil As New Perfil()
    Protected Overrides Sub PreLoad()
        Me.Icon = Icon.FromHandle(Global.SIPRO.My.Resources.Resources.User_group.GetHicon())
    End Sub
    Sub New()
        InitializeComponent()
    End Sub

    Sub New(perfil As Perfil)
        Me.New()
        _perfil = perfil
        btnGuardar.Tag = "Modificar"
        btnPermisos.Tag = "Modificar"
    End Sub

    Private Sub frmABMPerfil_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtNombre.DataBindings.Add("Text", _perfil, "Nombre")
    End Sub


    Private Sub OK_Click(sender As System.Object, e As System.EventArgs) Handles btnGuardar.Click
        If MyBase.ValidateForm() Then
            Try
                GesPerfiles.Guardar(_perfil)
                Me.Close()
                Me.DialogResult = Windows.Forms.DialogResult.OK
            Catch ex As Exception
                My.Application.HandlerException(New PerfilSaveException())
            End Try
        End If

    End Sub

    Private Sub Cancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancelar.Click
        Me.Close()
    End Sub


    Private Sub btnPermisos_Click(sender As System.Object, e As System.EventArgs) Handles btnPermisos.Click
        Dim f As New frmABMPermiso(_perfil)
        f.Show()
    End Sub
End Class